import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:yi_shop/route/index.dart';

///
/// 认证校验
///
class AuthGuard extends NavigatorObserver {
  /// 白名单路径
  List<String> whitePath = [RoutePath.login];

  /// token
  String get token {
    return 'token';
  }

  @override
  void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
    super.didPush(route, previousRoute);
    Get.log('route = ${route.toString()} name = ${route.settings.name}');
    if (route is GetPageRoute) {
      Get.log('GetRoute = ${route.settings}');
    }
    // if (!whitePath.contains(route.settings.name)) {
    //   /// 如果用户未登录，则重定向到登录页面
    //   Get.engine.addPostFrameCallback((_) {
    //     route.navigator?.pushReplacementNamed(RoutePath.login);
    //   });
    // }
  }
}
